<extend name="Public:bg_theme" />
<block name="content">
    <!-- bootstrap -->
    <script type="text/javascript" src="__PUBLIC__/js/bootstrap/js/bootstrap.js"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/js/bootstrap/css/bootstrap.css">
    <!-- x-editable -->
    <script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable-1.4.5/bootstrap-editable/js/bootstrap-editable.js"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/js/bootstrap-editable-1.4.5/bootstrap-editable/css/bootstrap-editable.css">
    <div class="location">
        <i>当前位置：</i>
        <gt name="_GET.pid" value="1">
        <a href="{:U('index?pid='.$current_parent['pid'])}" class="nav_a">返回上级</a>
        <else />
        <a href="javascript:;" class="nav_a">章节列表</a>
        </gt>
        <gt name="_GET.pid" value="1">
        <a href="javascript:;" class="nav_a">{$current_parent.title}</a>
        </gt>
    </div>
    <div class="title_form">
        <div class="title_search">
            <form action="{:U('')}" method="post">
                <label for="">中文名：</label>
                <input type="text" name="title" class="title_text input_style input_focus" value="{:I('title')}">
                <select name="pid">
                    <option value="0">请选择</option>
                    <volist name="nav_tree" id="cate">
                        <option value="{$cate.id}"<eq name="record.pid" value="$cate.id"> selected</eq>>{$cate.title_show}</option>
                    </volist>
                </select>
                <button class="find_btn" type="submit">搜索</button>
            </form>
        </div>
        <a href="{:U('add',array('pid'=>I('pid',0)))}"><button class="find_btn add_btn fl">新增</button></a>

        <button class="find_btn add_btn fr" id="sortButton" data-operate="__URL__/sort/value/Cate-">排序</button>
    </div>
    <div class="content_table">
        <form action="{:U('delete')}" method="post" id="del_form">
            <table id="del_table" class="data-table">
                <tr>
                    <th><input type="checkbox" name="checkAll"></th>
                    <th>操作</th>
                    <th>名称</th>
                    <th>上级章节</th>
                    <th>排序</th>
                </tr>
                <volist name="list" id="vo">
                    <tr>
                        <td>
                            <input type="checkbox" name="id[]" value="{$vo.id}" id="checkEach">
                        </td>
                        <td>
                            <a href="{:U('edit',array('id'=>$vo['id']))}">编辑</a>
                            <a href="{:U('index',array('pid'=>$vo['id']))}">进入</a>
                        </td>
                        <td>
                            <a href="javascript:;" class="editable" data-name="title" data-type="text" data-pk="{$vo.id}" data-url="{:U('ajaxUpdate')}">{$vo.title}</a>
                        </td>
                        <td>
                            <a href="javascript:;" class="editable group" data-name="pid" data-type="select" data-pk="{$vo.id}" data-source="{:U('editbleGetNav')}" sourceError="获取上级章节失败" data-url="{:U('ajaxUpdate')}" data-value="{$vo.pid}">{$vo.p_name}</a>
                        </td>
                        <td>
                            <a href="javascript:;" class="editable" data-name="sort" data-type="text" data-pk="{$vo.id}" data-url="{:U('ajaxUpdate')}">{$vo.sort}</a>
                        </td>
                    </tr>
                </volist>
            </table>
    </div>
    <div class="content_btn">
        <button class="find_btn" id="batch_del">删除</button>
    </div>
</form>
<script type="text/javascript">
    $(function() {
        //全选
        $("input[name='checkAll']").click(function() {
            $("input#checkEach").attr("checked", this.checked);
        })
        //初始化editable
        $('.editable').editable({
            emptytext: '空',
            success: function(response, newValue) {
                if (!response.status) {
                    return response.info;
                }
            }
        });

        //批量删除
        <include file="Public:batch_delete" />
    })
</script>
</block>
<block name="foot_js">
    $(function(){
    //左侧导航子页面高亮选中
    highlight_sidebar('{:U('index')}');
    });
</block>
